package com.collect.tanzania.zhiAdater.zhiDaily;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.collect.tanzania.R;
import com.collect.tanzania.zhiBean.zhiReceive.ZHIRCaseEntity;
import com.collect.tanzania.zhiHelper.ZHIPerfermanceHelper;

public class ZHIDailyListAdjuster extends BaseQuickAdapter<ZHIRCaseEntity, BaseViewHolder> {
    public ZHIDailyListAdjuster() {
        super(R.layout.item_daily_list_v2, null);
    }

    private OnDailyV2ItemClickListener mOnDailyItemClickListener;

    @Override
    protected void convert(BaseViewHolder helper, final ZHIRCaseEntity caseEntity) {

        helper.setText(R.id.tv_name, caseEntity.getFullName());
        helper.setText(R.id.tv_platform, caseEntity.getAppId());
        helper.setText(R.id.tv_mobile, caseEntity.getMobileEncryptFormatter());
        helper.setText(R.id.tv_overdue_days, caseEntity.getOverdueDay());
        helper.setText(R.id.tv_tag_num, caseEntity.getRecordNum());
        helper.setText(R.id.tv_tag_status, caseEntity.getLastContactResult());
        helper.setText(R.id.tv_follow_time_today, caseEntity.getDayFollowNumFormat());
        helper.addOnClickListener(R.id.ll_content);

//        TextView tv_part_repay = helper.getView(R.id.tv_part_repay);
//        tv_part_repay.setVisibility(caseEntity.isPartRepayFlag() ? View.VISIBLE : View.INVISIBLE);

        TextView tv_platform = helper.getView(R.id.tv_platform);
        tv_platform.setTextColor(ZHIPerfermanceHelper.getInstance().getRandomColorInRange());

        LinearLayout ll_idl_unfollow_flag = helper.getView(R.id.ll_idl_unfollow_flag);
        if (caseEntity.isTodayMarkFlag()) {
            ll_idl_unfollow_flag.setVisibility(View.GONE);
        } else {
            ll_idl_unfollow_flag.setVisibility(View.VISIBLE);
        }

        if (mOnDailyItemClickListener != null) {
            helper.getView(R.id.ll_content).setOnClickListener(view -> mOnDailyItemClickListener.OnItemClick(caseEntity));
        }
    }

    public void setOnOrderItemClickListener(OnDailyV2ItemClickListener onOrderItemClickListener) {
        this.mOnDailyItemClickListener = onOrderItemClickListener;
    }

    public interface OnDailyV2ItemClickListener {
        void OnItemClick(ZHIRCaseEntity caseEntity);
    }
}